<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    <base href="<?php echo base_url() ?>"/>
    <title>乐天！ &raquo; 首页</title>
    <meta name="generator" content="Order 1.0"/>
    <link rel="stylesheet" href="css/style.css" type="text/css"/>
    <link rel="stylesheet" href="jquery-ui/css/ui-lightness/jquery-ui-1.9.0.custom.min.css"/>
    <script src="jquery-ui/js/jquery-1.8.2.js" type="text/javascript" charset="utf-8"></script>
    <script src="jquery-ui/js/jquery-ui-1.9.0.custom.min.js" type="text/javascript" charset="utf-8"></script>

    <link rel="stylesheet" href="css/validationEngine.jquery.css" type="text/css"/>
    <script src="js/jquery.validationEngine-en.js" type="text/javascript" charset="utf-8"></script>
    <script src="js/jquery.validationEngine.js" type="text/javascript" charset="utf-8"></script>

    <script>
        $(function () {
            $(".link_mod").click(function () {
                var url = $(this).attr("href");
                $.post(url, function (result) {
                    var win_w = $('body').width() / 2;
                    $("#order_add").html(result);
                    $("#order_add").show().css({"position":"absolute", 'top':50, 'left':win_w - 420, "zIndex":"99999", "background-color":"#FFF"});
                    $("#bgDiv").show();
                });
                return false;
            })

            $(".quanxuan").click(function () {
                var tables = document.getElementsByTagName("table");
                var checkboxs = tables[0].getElementsByTagName("input");

                if (this.checked) {
                    for (var i = 0; i < checkboxs.length; i++) {
                        if (checkboxs[i].hidden == false) {
                            checkboxs[i].checked = true;
                        }
                    }
                }
                else {
                    for (var i = 0; i < checkboxs.length; i++) {
                        if (checkboxs[i].hidden == false) {
                            checkboxs[i].checked = false;
                        }
                    }
                }
            })

            $(".confirm").click(function () {
                var tables = document.getElementsByTagName("table");
                var checkboxs = tables[0].getElementsByTagName("input");
                var data = new Array();

                for (var i = 0; i < checkboxs.length; i++) {
                    if (checkboxs[i].checked) {
                        data.push(checkboxs[i].value);
                    }
                }
                if (data.length != 0) {
                    var url = this.name;

                    var turnForm = document.createElement("form");
                    //一定要加入到body中！！
                    document.body.appendChild(turnForm);
                    turnForm.method = 'post';
                    turnForm.action = url;
                    // turnForm.target = '_blank';
                    //创建隐藏表单
                    for (var i = 0; i < data.length; i++) {
                        var newElement = document.createElement("input");
                        newElement.setAttribute("name", i);
                        newElement.setAttribute("type", "hidden");
                        newElement.setAttribute("value", data[i]);
                        turnForm.appendChild(newElement);
                    }
                    turnForm.submit();
                }
                else {
                    $('#showup').html('请选择对象！');
                    $('#showup').fadeIn(1000);
                    $('#showup').fadeOut(3000);
                }
            })
        });
    </script>
    <style>
        .confirm {
            height: 32px;
            font-weight: bold;
            font-size: 12px;
            width: 80px;
            background: #7FA448;
            margin: 0;
            border: none;
            cursor: pointer;
            color: white;
            display: inline;
        }

        .confirm:hover {
            background: #8cb352;
        }
    </style>
</head>
<body>
<div id="order_detail" style="display: none;background:white;width:800px;padding:20px;margin:0px;">
</div>
<div id="bgDiv"></div>
<div id="order_add" style="display: none;background:white;width:800px;padding:20px;margin:0px;">
</div>

<div id="container">
<div id="header">
    <div id="header-inner">
        <h1><span><a href="#">乐天！</a></span></h1>

        <h2>订单管理系统</h2>

        <div class="clear"></div>
        <ul class="sw_menu">
            <li><a href=<?php echo site_url('login')?>  >首页</a></li>
            <li><a href=# class="sw_menu_current">管理</a></li>
            <li><a href=#>筛选</a></li>
            <?php
            if ($is_admin)
                echo '<li><a href=' . site_url('admin') . '>后台</a></li>';
            ?>
        </ul>
    </div>
</div>
<div id="sidebar">
    <div id="sidebar-inner">
        <ul>
            <li>
                                        <?php
                            if($ret['p1']){
                                echo  '<a  href='.site_url("order/new_order") .'>新建订单</a>';
                            }
                            else{
                               echo  '<a style="color:gray"  href="javascript:void(0)">新建订单</a>';
                            }
                            ?>
                           
                        </li>
                        <li>
                            <?php
                            if($ret['p2']){
                                echo  '<a  href='.site_url("order/wait_for_pay") .'>待付款订单</a>';
                            }
                            else{
                               echo  '<a style="color:gray"  href="javascript:void(0)">待付款订单</a>';
                            }
                            ?>
                        </li>
                        <li>
                            <?php
                            if($ret['p3']){
                                echo  '<a  href='.site_url("order/wait_for_buy") .'>待购货订单</a>';
                            }
                            else{
                               echo  '<a style="color:gray"  href="javascript:void(0)">待购货订单</a>';
                            }
                            ?>
                        </li>
                        <li class="select">>
                            <?php
                            if($ret['p4']){
                                echo  '<a  href='.site_url("order/wait_for_delivery") .'>待发货订单</a>';
                            }
                            else{
                               echo  '<a style="color:gray"  href="javascript:void(0)">待发货订单</a>';
                            }
                            ?>
                        </li>
                        <li>
                        <?php
                            if($ret['p5']){
                                echo  '<a  href='.site_url("order/order_allocation") .'>已发货订单</a>';
                            }
                            else{
                               echo  '<a style="color:gray"  href="javascript:void(0)">已发货订单</a>';
                            }
                            ?>                    
                        </li>
            <div class="clear"></div>
        </ul>
    </div>
</div>
<div class="clear"></div>
<div id="content-wrapper">
<div style=" position:absolute;top:20px;left:250px;display: none;line-height:40px;height: 40px;color:white; width:200px;font-size:16px;background:#cc6600;text-align: center;z-index:99;"
     id='showup'>正在提交订单
</div>
<div id="content">
    <div>
        <div style="float:left;">
            <h3 id="comments-title"><em>已配货待发货订单</em></h3>
        </div>
        <div style="float:right;">
            全选
            <input type="checkbox" name="quanxuan" class="quanxuan"/>
            <?php
            $data = array(
                'name' => site_url("order/wait_for_delivery_confirm/" . $num),
                'id' => 'button',
                'value' => '确认已发货',
                'type' => 'button',
                'class' => 'confirm',
            );
            echo form_input($data);
            ?>
        </div>
        <div class="clear"></div>
    </div>
    <div class="comment-form">
        <table>
            <tr>
                <th>勾选</th>
                <th>状态</th>
                <th>日期</th>
                <th>订单号</th>
                <th>商品编号</th>
                <th style="width:134px">图片</th>
                <th>销售链接</th>
                <th>颜色/尺码</th>
                <th>数量</th>
                <th>单价</th>
                <th>金额</th>
                <th>运费</th>
                <th>总额</th>
                <th>客户信息</th>
                <th style="width: 60px">收款方式</th>
                <th>入账日期</th>
                <th style="width: 120px">添加修改</th>
            </tr>
            <?php
            $pre = -1;
            $data = array();
            if (!empty($list)) {
                foreach ($list as $k => $v) {
                    if ($pre == $v['id']) {
                        $data[] = $v;
                    } else {
                        if (count($data) != 0) {
                            echo "<tr>";
                            if ($data[0]['statehidden'] == '1') {
                                echo "<td rowspan='" . count($data) . "'>";
                                $input_data = array(
                                    "value" => $data[0]['id'],
                                    "checked" => '0',
                                );
                                echo form_checkbox($input_data);
                                echo "</td>";
                                echo "<td rowspan='" . count($data) . "'>";
                                echo "已填写发货信息";
                                echo "</td>";
                            } else {
                                echo "<td rowspan='" . count($data) . "'>";
                                $input_data = array(
                                    "value" => $data[0]['id'],
                                    "hidden" => 'true',
                                );
                                echo form_checkbox($input_data);
                                echo "</td>";
                                echo "<td rowspan='" . count($data) . "'>";
                                echo "未填写发货信息";
                                echo "</td>";
                            }
                            echo "<td>" . $data[0]['orderTime'] . "</td>";
                            echo "<td>" . $data[0]['orderNumber'] . "</td>";
                            echo "<td>" . $data[0]['commodityNumber'] . "</td>";
                            echo "<td><div style=\"border:1px solid #ffecf1;padding:3px;background-color:#efefef\">
<img src='" . $data[0]['imagePath'] . "'width='126px' height='150px' /></div></td>";
                            echo "<td><a href='" . $data[0]['link'] . "' target='_blank' >" . $data[0]['link'] . "</a></td>";
                            echo "<td>" . $data[0]['colorAndSize'] . "</td>";
                            echo "<td>" . $data[0]['amount'] . "</td>";
                            echo "<td>" . $data[0]['unitPrice'] . "</td>";
                            echo "<td>" . $data[0]['money'] . "</td>";
                            echo "<td>" . $data[0]['deliveryMoney'] . "</td>";
                            echo "<td>" . $data[0]['total'] . "</td>";
                            echo "<td>" . $data[0]['clientInfo'] . "</td>";
                            echo "<td>" . $data[0]['paymentMethod'] . "</td>";
                            echo "<td>" . $data[0]['cashEntryTime'] . "</td>";
                            if ($data[0]['statehidden'] == '0') {
                                echo "<td rowspan='" . count($data) . "'><a href='" . site_url("order/wait_for_delivery_add/" . $data[0]['id'] . "/" . $num) . "' class='link_mod'>&nbsp;</a></td>";
                            } else {
                                echo "<td rowspan='" . count($data) . "'><a href='" . site_url("order/wait_for_delivery_alter/" . $data[0]['id'] . "/" . $num) . "' class='link_mod'>&nbsp;</a></td>";
                            }
                            echo "</tr>";

                            for ($i = 1; $i < count($data); $i++) {
                                echo "<tr>";
                                echo "<td>" . $data[$i]['orderTime'] . "</td>";
                                echo "<td>" . $data[$i]['orderNumber'] . "</td>";
                                echo "<td>" . $data[$i]['commodityNumber'] . "</td>";
                                echo "<td><div style=\"border:1px solid #ffecf1;padding:3px;background-color:#efefef\">
<img src='" . $data[$i]['imagePath'] . "'width='126px' height='150px' /></div></td>";
                                echo "<td><a href='" . $data[$i]['link'] . "' target='_blank' >" . $data[$i]['link'] . "</a></td>";
                                echo "<td>" . $data[$i]['colorAndSize'] . "</td>";
                                echo "<td>" . $data[$i]['amount'] . "</td>";
                                echo "<td>" . $data[$i]['unitPrice'] . "</td>";
                                echo "<td>" . $data[$i]['money'] . "</td>";
                                echo "<td>" . $data[$i]['deliveryMoney'] . "</td>";
                                echo "<td>" . $data[$i]['total'] . "</td>";
                                echo "<td>" . $data[$i]['clientInfo'] . "</td>";
                                echo "<td>" . $data[$i]['paymentMethod'] . "</td>";
                                echo "<td>" . $data[$i]['cashEntryTime'] . "</td>";
                                echo "</tr>";
                            }
                        }
                        $pre = $v['id'];
                        $data = array();
                        $data[] = $v;
                    }
                }
                if (count($data) != 0) {
                    echo "<tr>";
                    if ($data[0]['statehidden'] == '1') {
                        echo "<td rowspan='" . count($data) . "'>";
                        $input_data = array(
                            "value" => $data[0]['id'],
                            "checked" => '0',
                        );
                        echo form_checkbox($input_data);
                        echo "</td>";
                        echo "<td rowspan='" . count($data) . "'>";
                        echo "已填写发货信息";
                        echo "</td>";
                    } else {
                        echo "<td rowspan='" . count($data) . "'>";
                        $input_data = array(
                            "value" => $data[0]['id'],
                            "hidden" => 'true',
                        );
                        echo form_checkbox($input_data);
                        echo "</td>";
                        echo "<td rowspan='" . count($data) . "'>";
                        echo "未填写发货信息";
                        echo "</td>";
                    }
                    echo "<td>" . $data[0]['orderTime'] . "</td>";
                    echo "<td>" . $data[0]['orderNumber'] . "</td>";
                    echo "<td>" . $data[0]['commodityNumber'] . "</td>";
                    echo "<td><div style=\"border:1px solid #ffecf1;padding:3px;background-color:#efefef\">
<img src='" . $data[0]['imagePath'] . "'width='126px' height='150px' /></div></td>";
                    echo "<td><a href='" . $data[0]['link'] . "' target='_blank' >" . $data[0]['link'] . "</a></td>";
                    echo "<td>" . $data[0]['colorAndSize'] . "</td>";
                    echo "<td>" . $data[0]['amount'] . "</td>";
                    echo "<td>" . $data[0]['unitPrice'] . "</td>";
                    echo "<td>" . $data[0]['money'] . "</td>";
                    echo "<td>" . $data[0]['deliveryMoney'] . "</td>";
                    echo "<td>" . $data[0]['total'] . "</td>";
                    echo "<td>" . $data[0]['clientInfo'] . "</td>";
                    echo "<td>" . $data[0]['paymentMethod'] . "</td>";
                    echo "<td>" . $data[0]['cashEntryTime'] . "</td>";
                    if ($data[0]['statehidden'] == '0') {
                        echo "<td rowspan='" . count($data) . "'><a href='" . site_url("order/wait_for_delivery_add/" . $data[0]['id'] . "/" . $num) . "' class='link_mod'>&nbsp;</a></td>";
                    } else {
                        echo "<td rowspan='" . count($data) . "'><a href='" . site_url("order/wait_for_delivery_alter/" . $data[0]['id'] . "/" . $num) . "' class='link_mod'>&nbsp;</a></td>";
                    }
                    echo "</tr>";

                    for ($i = 1; $i < count($data); $i++) {
                        echo "<tr>";
                        echo "<td>" . $data[$i]['orderTime'] . "</td>";
                        echo "<td>" . $data[$i]['orderNumber'] . "</td>";
                        echo "<td>" . $data[$i]['commodityNumber'] . "</td>";
                        echo "<td><div style=\"border:1px solid #ffecf1;padding:3px;background-color:#efefef\">
<img src='" . $data[$i]['imagePath'] . "'width='126px' height='150px' /></div></td>";
                        echo "<td><a href='" . $data[$i]['link'] . "' target='_blank' >" . $data[$i]['link'] . "</a></td>";
                        echo "<td>" . $data[$i]['colorAndSize'] . "</td>";
                        echo "<td>" . $data[$i]['amount'] . "</td>";
                        echo "<td>" . $data[$i]['unitPrice'] . "</td>";
                        echo "<td>" . $data[$i]['money'] . "</td>";
                        echo "<td>" . $data[$i]['deliveryMoney'] . "</td>";
                        echo "<td>" . $data[$i]['total'] . "</td>";
                        echo "<td>" . $data[$i]['clientInfo'] . "</td>";
                        echo "<td>" . $data[$i]['paymentMethod'] . "</td>";
                        echo "<td>" . $data[$i]['cashEntryTime'] . "</td>";
                        echo "</tr>";
                    }
                }
            }
            ?>
        </table>
        <div class="clear"></div>
        <?php echo $this->pagination->create_links(); ?>
        <div class="clear"></div>
    </div>
</div>
<div class="clear"></div>
<div id="footer">
    <hr/>
    <ul>
        <li>
            Powered by <a href=#>Swan 1.3.0</a>
        </li>
    </ul>
</div>
</div>
</div>
</body>
</html>

